package com.yq.design.flyWeight;

import com.yq.design.flyWeight.simple.Factory;

/**
 * @ClassName Client
 * @Description 享元模式，共享对象
 * @Author yaoqiang
 * @Date 2021/2/22 23:53
 * @Version 1.0
 */
public class Client {
    public static void main(String[] args) {
        testSimple();
    }

    public static void testSimple(){
        Factory factory=new Factory();
        Object aNew = factory.getWeb("new");
        Object blog = factory.getWeb("blog");
        Object blog2 = factory.getWeb("blog");

    }

    public static  void test(){
        //创建一个工厂类
        FlyWeightFactory flyWeightFactory = new FlyWeightFactory();
//以新闻形式发布网站
        WebSite webSite1 = flyWeightFactory.getWebSite("news");
        webSite1.use(new User("user1"));
        webSite1.print();
        WebSite webSite2 = flyWeightFactory.getWebSite("blog");
        webSite2.use(new User("user2"));
        webSite2.print();
        WebSite webSite3 = flyWeightFactory.getWebSite("blog");
        webSite3.use(new User("user3"));

        flyWeightFactory.getLength();
    }
}
